<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <div th:include="/layout/head :: head"></div>
</head>
<body>

<div th:include="/layout/navbar :: navbar"></div>


<div class="container" style="margin-top: 50px;">
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">
            异常列表 <span class="text-danger">注：时间范围选择请不要超过一天,历史数据保存一个月</span>
        </div>
        <div class="panel-body">
            <div class="col-lg-12">
                <div class="input-group">
                    <select class="selectpicker show-tick form-control" data-live-search="true" data-width="280px"
                            id="appId" name="appId" th:remove="all-but-first">
                        <option th:each="entry : ${appIdMap.entrySet()}"
                                th:value="${entry.key}" th:text="${entry.value}"
                                th:selected="${#strings.equals(#httpServletRequest.getParameter('appId'),entry.key)}"></option>
                    </select>
                    <select class="form-control" id="errorLevel" name="errorLevel" th:remove="all-but-first">
                        <option th:each="entry : ${errorLevelMap.entrySet()}"
                                th:value="${entry.key}" th:text="${entry.value}"
                                th:selected="${#strings.equals(#httpServletRequest.getParameter('errorLevel'),entry.key)}"></option>
                    </select>
                    <input id="machineIp" name="machineIp" type="text" class="form-control"
                           placeholder="服务器IP地址"
                           th:value="${machineIp}"/>
                    <input id="keyWord" name="keyWord" type="text" class="form-control"
                           placeholder="关键字"
                           th:value="${keyWord}"/>
                    <input id="beginTime" name="beginTime" type="text" class="form-control form_datetime"
                           placeholder="开始时间"
                           th:value="${beginTime}"/>

                    <input id="endTime" name="endTime" type="text" class="form-control form_datetime"
                           placeholder="结束时间"
                           th:value="${endTime}"/>

                    <span class="input-group-btn">
                    <button class="btn btn-default" type="button" onclick="search();"><span
                            class="glyphicon glyphicon-search"
                            aria-hidden="true"></span>查 询
                    </button>
                    </span>
                </div>
            </div>

        </div>

    </div>

    <table class="table table-bordered table table-hover">
        <thead>
        <tr>

            <th width="150">报错标题</th>
            <th width="100">报错信息</th>
            <th width="150">报错时间</th>
            <th width="70">错误级别</th>
            <th width="80">错误类型</th>
            <th width="100">机器Ip</th>
        </tr>
        </thead>
        <tbody th:remove="all-but-first">
        <tr th:each="log:${list}" th:id="${log.id}">

            <td style="word-break: break-all; word-wrap:break-word;">
                <a th:href="|javascript:showDetail('${log.id}','${log.date}');|"
                   th:text="${log.title}"></a>
            </td>

            <td style="word-break: break-all; word-wrap:break-word;" th:text="${log.message}"></td>
            <td style="word-break: break-all; word-wrap:break-word;" th:text="${log.addTime}"></td>
            <td style="word-break: break-all; word-wrap:break-word;" th:text="${log.errorLevel}"></td>
            <td style="word-break: break-all; word-wrap:break-word;" th:text="${log.exceptionName}"></td>
            <td th:text="${log.machineIp}"></td>
        </tr>
        </tbody>
    </table>
    <div th:include="/layout/footer :: footer"></div>
    <div th:include="/layout/paging :: paging (${totalRecords},${pageSize},${pageIndex})"></div>
</div>

<script language="javascript" type="application/javascript" xmlns:th="http://www.w3.org/1999/xhtml"
        th:inline="javascript">
    function redirectPage(pageIndex) {
        var appId = $("#appId").val().trim();
        var errorLevel = $("#errorLevel").val().trim();
        var beginTime = $("#beginTime").val().trim();
        var endTime = $("#endTime").val().trim();
        var machineIp = $("#machineIp").val().trim();
        var keyWord = $("#keyWord").val().trim();
        /*<![CDATA[*/
        var url = '/exception/list?pageIndex=' + pageIndex + '&appId=' + appId + '&errorLevel='
            + errorLevel + '&beginTime=' + beginTime + '&endTime=' + endTime + '&machineIp=' + machineIp + '&keyWord=' + keyWord;
        ;
        /*]]>*/
        window.location.href = url;
    }

    function search() {
        redirectPage(1);
    }

    function showDetail(id, date) {
        /*<![CDATA[*/
        var url = '/exception/detail?id=' + id + "&date=" + date;
        /*]]>*/
        window.open(url);
    }
</script>
</body>
</html>

